#include "searchdialog.h"
#include "ui_searchdialog.h"

SearchDialog::SearchDialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::SearchDialog)
{
    ui->setupUi(this);
    connect(ui->pbCancel, SIGNAL(clicked()), this, SLOT(reject()));
    connect(ui->pbFind, SIGNAL(clicked()), this, SLOT(accept()));
}

SearchDialog::~SearchDialog()
{
    delete ui;
}

QByteArray SearchDialog::getSearchBytes()
{
    const QString &text = ui->cbFindString->currentText();
    int type = ui->cbFindType->currentIndex();

    QByteArray bytes;
    switch (type) {
        case 0: // hex
            bytes = QByteArray::fromHex(text.toLatin1());
            break;
        case 1: // text
            bytes = text.toUtf8();
            break;
    }
    return bytes;
}
